#***********************************************************************************
#* Code license:  GNU General Public License v3                                    *
#* Main page:     https://code.google.com/p/library-cross-platform/                *
#* Issue tracker: https://code.google.com/p/library-cross-platform/issues/list     *
#***********************************************************************************

include $(HOME_DIR)/include.mk
include $(HOME_DIR)/target.mk

PARSER_INCLUDE = -I$(HOME_DIR) -I$(PARSER_DIR)


PARSER_C_FILES =
PARSER_CC_FILES =
PARSER_CPP_FILES =                   \
    $(PARSER_DIR)/parser.cpp         \
    $(PARSER_DIR)/parserstate.cpp    \
    $(PARSER_DIR)/asciiparser.cpp


ifeq ($(platform), linux)
  PARSER_C_FILES =
  PARSER_CC_FILES =
  PARSER_CPP_FILES +=                \
    $(PARSER_DIR_LINUX)/rexp.cpp

endif

ifeq ($(platform), win)
  PARSER_C_FILES =
  PARSER_CC_FILES =
  PARSER_CPP_FILES +=                \
    $(PARSER_DIR_WINDOWS)/rexp.cpp

endif

OBJECTS_PARSER := $(PARSER_C_FILES:.c=_$(target).o) $(PARSER_CC_FILES:.cc=_$(target).o) $(PARSER_CPP_FILES:.cpp=_$(target).o)

parser_compile: $(OBJECTS_PARSER)

%_$(target).o: %.cpp
	$(CC) $(DEBUG) $(CFLAGS) $(DEFINE) $(PARSER_INCLUDE) -o $@ -c $<

%_$(target).o: %.c
	$(CC) $(DEBUG) $(CFLAGS) $(DEFINE) $(PARSER_INCLUDE) -o $@ $<

%_$(target).o: %.cc
	$(CC) $(DEBUG) $(CFLAGS) $(DEFINE) $(PARSER_INCLUDE) -o $@ $<

.PHONY : parser_clean
parser_clean:
	\rm -rf $(OBJECTS_PARSER)
#	\rm -rf $(PARSER_DIR)/*.o 


#example build target
#RESULT_FILE = test.o
#parser_build: $(OBJECTS_PARSER)
#	$(CC) -o $(RESULT_FILE) $^
